package com.ts.base.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * Knife4j swagger configuration file
 * pom.xml 需要增加dependency
 * 		<!--https://doc.xiaominfo.com/knife4j/ -->
 * 		<dependency>
 * 			<groupId>com.github.xiaoymin</groupId>
 * 			<artifactId>knife4j-spring-boot-starter</artifactId>
 * 			<version>2.0.7</version>
 * 		</dependency>
 * 		<!-- knife4j End -->
 * http://localhost:8080/doc.html#/home
 */

@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfiguration {

    @Bean
    public Docket createRestApi() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("河北东软唐山现场 spring boot restful-api接口说明")
                        .description("# base project RESTful APIs")
                        .version("0.1")
                        .termsOfServiceUrl("http://localhost:8080/doc.html#/home")
                        .build())
                //分组名称
                .groupName("0.1版本")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }


}
